package com.lcj.crawler;

import com.geccocrawler.gecco.pipeline.Pipeline;
import com.lcj.service.CompanyRecruitInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SaveZptRecruitPipeline implements Pipeline<ZptRecruitPage> {

    @Resource(name="companyRecruitInfoServiceImpl")
    private CompanyRecruitInfoService companyRecruitInfoService;
    @Override
    public void process(ZptRecruitPage zptRecruitPage) {
        String recruitId = zptRecruitPage.getRecruitId();
        String recruitUrl = "https://www.zptong.com/jobs/jobs-show-"+recruitId+"-.htm";
        String lowerEdu ="";
        String industryName = "";
        String persons = "";
        String recruitDate = "";
        if(zptRecruitPage.getLowerEdu()!=null){
            lowerEdu = zptRecruitPage.getLowerEdu();
        }
        if(zptRecruitPage.getIndustryName()!=null){
            industryName = zptRecruitPage.getIndustryName();
        }
        if(zptRecruitPage.getPersons()!=null){
            persons = zptRecruitPage.getPersons();
        }
        if(zptRecruitPage.getRecruitDate()!=null){
            recruitDate = zptRecruitPage.getRecruitDate();
        }
        companyRecruitInfoService.updateZpt(recruitUrl,lowerEdu,industryName,persons,recruitDate);
    }
}
